package com.example.springbootdemo.utils;

import com.example.springbootdemo.base.BaseResult;

/**
 * 请求回调
 */
public class ResultUtil {

    /**
     * 请求成功(含有返回值)
     *
     * @param object
     * @return
     */
    public static BaseResult success(Object object) {
        BaseResult result = new BaseResult();
        result.setCode(0);
        result.setMessage("请求成功");
        result.setData(object);
        return result;
    }

    /**
     * 请求成功(不含返回值)
     *
     * @return
     */
    public static BaseResult success() {
        return success(null);
    }

    /**
     * 请求失败
     *
     * @return
     */
    public static BaseResult failed(Integer code, String message) {
        BaseResult result = new BaseResult();
        result.setCode(code);
        result.setMessage(message);
        result.setData("");
        return result;
    }
}
